.class Lcom/netease/newsreader/activity/ShareToMicroBlog$postEditMessage4Ydnote;
.super Ljava/lang/Thread;
.source "ShareToMicroBlog.java"


# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lcom/netease/newsreader/activity/ShareToMicroBlog;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x0
    name = "postEditMessage4Ydnote"
.end annotation


# instance fields
.field private content:Ljava/lang/String;

.field private source:Ljava/lang/String;

.field final synthetic this$0:Lcom/netease/newsreader/activity/ShareToMicroBlog;

.field private title:Ljava/lang/String;

.field private token:Ljava/lang/String;

.field private tokenSecret:Ljava/lang/String;


# direct methods
.method public constructor <init>(Lcom/netease/newsreader/activity/ShareToMicroBlog;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
    .locals 0
    .parameter
    .parameter "title"
    .parameter "content"
    .parameter "source"
    .parameter "token"
    .parameter "tokenSecret"

    .prologue
    .line 970
    iput-object p1, p0, Lcom/netease/newsreader/activity/ShareToMicroBlog$postEditMessage4Ydnote;->this$0:Lcom/netease/newsreader/activity/ShareToMicroBlog;

    .line 964
    invoke-direct {p0}, Ljava/lang/Thread;-><init>()V

    .line 965
    iput-object p2, p0, Lcom/netease/newsreader/activity/ShareToMicroBlog$postEditMessage4Ydnote;->title:Ljava/lang/String;

    .line 966
    iput-object p3, p0, Lcom/netease/newsreader/activity/ShareToMicroBlog$postEditMessage4Ydnote;->content:Ljava/lang/String;

    .line 967
    iput-object p4, p0, Lcom/netease/newsreader/activity/ShareToMicroBlog$postEditMessage4Ydnote;->source:Ljava/lang/String;

    .line 968
    iput-object p5, p0, Lcom/netease/newsreader/activity/ShareToMicroBlog$postEditMessage4Ydnote;->token:Ljava/lang/String;

    .line 969
    iput-object p6, p0, Lcom/netease/newsreader/activity/ShareToMicroBlog$postEditMessage4Ydnote;->tokenSecret:Ljava/lang/String;

    return-void
.end method


# virtual methods
.method public run()V
    .locals 20

    .prologue
    .line 973
    new-instance v7, Landroid/os/Message;

    invoke-direct {v7}, Landroid/os/Message;-><init>()V

    .line 974
    .local v7, msg:Landroid/os/Message;
    const/16 v17, 0x1

    move/from16 v0, v17

    iput v0, v7, Landroid/os/Message;->what:I

    .line 975
    const/16 v17, 0x1

    move/from16 v0, v17

    iput v0, v7, Landroid/os/Message;->arg1:I

    .line 977
    :try_start_0
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/netease/newsreader/activity/ShareToMicroBlog$postEditMessage4Ydnote;->this$0:Lcom/netease/newsreader/activity/ShareToMicroBlog;

    move-object/from16 v17, v0

    invoke-virtual/range {v17 .. v17}, Lcom/netease/newsreader/activity/ShareToMicroBlog;->getShortUrl()Ljava/lang/String;

    move-result-object v15

    .line 978
    .local v15, temppicurl:Ljava/lang/String;
    new-instance v17, Ljava/lang/StringBuilder;

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/netease/newsreader/activity/ShareToMicroBlog$postEditMessage4Ydnote;->content:Ljava/lang/String;

    move-object/from16 v18, v0

    const-string v19, "<--insert-->"

    move-object/from16 v0, v18

    move-object/from16 v1, v19

    invoke-virtual {v0, v1, v15}, Ljava/lang/String;->replace(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String;

    move-result-object v18

    invoke-static/range {v18 .. v18}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v18

    invoke-direct/range {v17 .. v18}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/netease/newsreader/activity/ShareToMicroBlog$postEditMessage4Ydnote;->this$0:Lcom/netease/newsreader/activity/ShareToMicroBlog;

    move-object/from16 v18, v0

    invoke-static/range {v18 .. v18}, Lcom/netease/newsreader/activity/ShareToMicroBlog;->access$16(Lcom/netease/newsreader/activity/ShareToMicroBlog;)Ljava/lang/String;

    move-result-object v18

    invoke-virtual/range {v17 .. v18}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v17

    invoke-virtual/range {v17 .. v17}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v17

    move-object/from16 v0, v17

    move-object/from16 v1, p0

    iput-object v0, v1, Lcom/netease/newsreader/activity/ShareToMicroBlog$postEditMessage4Ydnote;->content:Ljava/lang/String;

    .line 979
    new-instance v16, Lcom/netease/newsreader/weibo/YdNoteLoginHelper;

    invoke-direct/range {v16 .. v16}, Lcom/netease/newsreader/weibo/YdNoteLoginHelper;-><init>()V

    .line 980
    .local v16, ydnoteHelper:Lcom/netease/newsreader/weibo/YdNoteLoginHelper;
    invoke-virtual/range {v16 .. v16}, Lcom/netease/newsreader/weibo/YdNoteLoginHelper;->getOAuthAccess()Lnet/oauth/OAuthAccessor;

    move-result-object v3

    .line 981
    .local v3, accessor:Lnet/oauth/OAuthAccessor;
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/netease/newsreader/activity/ShareToMicroBlog$postEditMessage4Ydnote;->tokenSecret:Ljava/lang/String;

    move-object/from16 v17, v0

    move-object/from16 v0, v17

    iput-object v0, v3, Lnet/oauth/OAuthAccessor;->tokenSecret:Ljava/lang/String;

    .line 982
    new-instance v9, Ljava/util/Properties;

    invoke-direct {v9}, Ljava/util/Properties;-><init>()V

    .line 983
    .local v9, oauthInfo:Ljava/util/Properties;
    const-string v17, "oauth_token"

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/netease/newsreader/activity/ShareToMicroBlog$postEditMessage4Ydnote;->token:Ljava/lang/String;

    move-object/from16 v18, v0

    move-object/from16 v0, v17

    move-object/from16 v1, v18

    invoke-virtual {v9, v0, v1}, Ljava/util/Properties;->setProperty(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Object;

    .line 986
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/netease/newsreader/activity/ShareToMicroBlog$postEditMessage4Ydnote;->this$0:Lcom/netease/newsreader/activity/ShareToMicroBlog;

    move-object/from16 v17, v0

    invoke-static/range {v17 .. v17}, Lcom/netease/newsreader/activity/ShareToMicroBlog;->access$22(Lcom/netease/newsreader/activity/ShareToMicroBlog;)Landroid/content/SharedPreferences;

    move-result-object v17

    const-string v18, "ydnote_default_notebook_path"

    const/16 v19, 0x0

    invoke-interface/range {v17 .. v19}, Landroid/content/SharedPreferences;->getString(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v8

    .line 988
    .local v8, notebook:Ljava/lang/String;
    const/4 v12, 0x0

    .line 989
    .local v12, response:Lorg/apache/http/HttpResponse;
    invoke-static {v8}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v17

    if-eqz v17, :cond_0

    .line 990
    invoke-virtual/range {v16 .. v16}, Lcom/netease/newsreader/weibo/YdNoteLoginHelper;->getHttpClient()Lorg/apache/http/impl/client/DefaultHttpClient;

    move-result-object v17

    .line 991
    new-instance v18, Ljava/lang/StringBuilder;

    invoke-static {}, Lcom/netease/newsreader/weibo/YdNoteLoginHelper;->getBaseUrl()Ljava/lang/String;

    move-result-object v19

    invoke-static/range {v19 .. v19}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v19

    invoke-direct/range {v18 .. v19}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v19, "yws/open/notebook/all.json"

    invoke-virtual/range {v18 .. v19}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v18

    invoke-virtual/range {v18 .. v18}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v18

    new-instance v19, Ljava/util/Properties;

    invoke-direct/range {v19 .. v19}, Ljava/util/Properties;-><init>()V

    .line 990
    move-object/from16 v0, v17

    move-object/from16 v1, v18

    move-object/from16 v2, v19

    invoke-static {v0, v1, v3, v9, v2}, Lcom/netease/newsreader/weibo/OAuthHelper;->requestPostUrlEncode(Lorg/apache/http/client/HttpClient;Ljava/lang/String;Lnet/oauth/OAuthAccessor;Ljava/util/Properties;Ljava/util/Properties;)Lorg/apache/http/HttpResponse;

    move-result-object v12

    .line 993
    invoke-interface {v12}, Lorg/apache/http/HttpResponse;->getEntity()Lorg/apache/http/HttpEntity;

    move-result-object v17

    const-string v18, "utf-8"

    invoke-static/range {v17 .. v18}, Lorg/apache/http/util/EntityUtils;->toString(Lorg/apache/http/HttpEntity;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v13

    .line 996
    .local v13, responseNoteBookStr:Ljava/lang/String;
    new-instance v6, Lorg/json/JSONArray;

    invoke-direct {v6, v13}, Lorg/json/JSONArray;-><init>(Ljava/lang/String;)V

    .line 997
    .local v6, jsonArray:Lorg/json/JSONArray;
    const/16 v17, 0x0

    move/from16 v0, v17

    invoke-virtual {v6, v0}, Lorg/json/JSONArray;->getJSONObject(I)Lorg/json/JSONObject;

    move-result-object v5

    .line 999
    .local v5, json:Lorg/json/JSONObject;
    const-string v17, "path"

    move-object/from16 v0, v17

    invoke-virtual {v5, v0}, Lorg/json/JSONObject;->get(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v8

    .end local v8           #notebook:Ljava/lang/String;
    check-cast v8, Ljava/lang/String;

    .line 1000
    .restart local v8       #notebook:Ljava/lang/String;
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/netease/newsreader/activity/ShareToMicroBlog$postEditMessage4Ydnote;->this$0:Lcom/netease/newsreader/activity/ShareToMicroBlog;

    move-object/from16 v17, v0

    invoke-static/range {v17 .. v17}, Lcom/netease/newsreader/activity/ShareToMicroBlog;->access$22(Lcom/netease/newsreader/activity/ShareToMicroBlog;)Landroid/content/SharedPreferences;

    move-result-object v17

    invoke-interface/range {v17 .. v17}, Landroid/content/SharedPreferences;->edit()Landroid/content/SharedPreferences$Editor;

    move-result-object v17

    const-string v18, "ydnote_default_notebook_path"

    move-object/from16 v0, v17

    move-object/from16 v1, v18

    invoke-interface {v0, v1, v8}, Landroid/content/SharedPreferences$Editor;->putString(Ljava/lang/String;Ljava/lang/String;)Landroid/content/SharedPreferences$Editor;

    move-result-object v17

    invoke-interface/range {v17 .. v17}, Landroid/content/SharedPreferences$Editor;->commit()Z

    .line 1001
    const/4 v12, 0x0

    .line 1004
    .end local v5           #json:Lorg/json/JSONObject;
    .end local v6           #jsonArray:Lorg/json/JSONArray;
    .end local v13           #responseNoteBookStr:Ljava/lang/String;
    :cond_0
    new-instance v11, Ljava/util/Properties;

    invoke-direct {v11}, Ljava/util/Properties;-><init>()V

    .line 1005
    .local v11, postParams:Ljava/util/Properties;
    const-string v17, "notebook"

    move-object/from16 v0, v17

    invoke-virtual {v11, v0, v8}, Ljava/util/Properties;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 1006
    const-string v17, "source"

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/netease/newsreader/activity/ShareToMicroBlog$postEditMessage4Ydnote;->source:Ljava/lang/String;

    move-object/from16 v18, v0

    move-object/from16 v0, v17

    move-object/from16 v1, v18

    invoke-virtual {v11, v0, v1}, Ljava/util/Properties;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 1007
    const-string v17, "title"

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/netease/newsreader/activity/ShareToMicroBlog$postEditMessage4Ydnote;->title:Ljava/lang/String;

    move-object/from16 v18, v0

    move-object/from16 v0, v17

    move-object/from16 v1, v18

    invoke-virtual {v11, v0, v1}, Ljava/util/Properties;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 1008
    const-string v17, "content"

    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/netease/newsreader/activity/ShareToMicroBlog$postEditMessage4Ydnote;->content:Ljava/lang/String;

    move-object/from16 v18, v0

    move-object/from16 v0, v17

    move-object/from16 v1, v18

    invoke-virtual {v11, v0, v1}, Ljava/util/Properties;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 1010
    invoke-virtual/range {v16 .. v16}, Lcom/netease/newsreader/weibo/YdNoteLoginHelper;->getHttpClient()Lorg/apache/http/impl/client/DefaultHttpClient;

    move-result-object v17

    .line 1011
    new-instance v18, Ljava/lang/StringBuilder;

    invoke-static {}, Lcom/netease/newsreader/weibo/YdNoteLoginHelper;->getBaseUrl()Ljava/lang/String;

    move-result-object v19

    invoke-static/range {v19 .. v19}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v19

    invoke-direct/range {v18 .. v19}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v19, "yws/open/note/create.json"

    invoke-virtual/range {v18 .. v19}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v18

    invoke-virtual/range {v18 .. v18}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v18

    .line 1010
    move-object/from16 v0, v17

    move-object/from16 v1, v18

    invoke-static {v0, v1, v3, v9, v11}, Lcom/netease/newsreader/weibo/OAuthHelper;->requestPostMultiPart(Lorg/apache/http/client/HttpClient;Ljava/lang/String;Lnet/oauth/OAuthAccessor;Ljava/util/Properties;Ljava/util/Properties;)Lorg/apache/http/HttpResponse;

    move-result-object v12

    .line 1013
    invoke-interface {v12}, Lorg/apache/http/HttpResponse;->getEntity()Lorg/apache/http/HttpEntity;

    move-result-object v17

    const-string v18, "utf-8"

    invoke-static/range {v17 .. v18}, Lorg/apache/http/util/EntityUtils;->toString(Lorg/apache/http/HttpEntity;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v14

    .line 1017
    .local v14, responseStr:Ljava/lang/String;
    new-instance v10, Lorg/json/JSONObject;

    invoke-direct {v10, v14}, Lorg/json/JSONObject;-><init>(Ljava/lang/String;)V

    .line 1018
    .local v10, obj:Lorg/json/JSONObject;
    if-eqz v10, :cond_1

    const-string v17, "path"

    move-object/from16 v0, v17

    invoke-virtual {v10, v0}, Lorg/json/JSONObject;->isNull(Ljava/lang/String;)Z

    move-result v17

    if-nez v17, :cond_1

    const-string v17, "path"

    move-object/from16 v0, v17

    invoke-virtual {v10, v0}, Lorg/json/JSONObject;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v17

    invoke-virtual/range {v17 .. v17}, Ljava/lang/String;->length()I

    move-result v17

    if-lez v17, :cond_1

    .line 1019
    const/16 v17, 0x0

    move/from16 v0, v17

    iput v0, v7, Landroid/os/Message;->arg1:I
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 1026
    .end local v3           #accessor:Lnet/oauth/OAuthAccessor;
    .end local v8           #notebook:Ljava/lang/String;
    .end local v9           #oauthInfo:Ljava/util/Properties;
    .end local v10           #obj:Lorg/json/JSONObject;
    .end local v11           #postParams:Ljava/util/Properties;
    .end local v12           #response:Lorg/apache/http/HttpResponse;
    .end local v14           #responseStr:Ljava/lang/String;
    .end local v15           #temppicurl:Ljava/lang/String;
    .end local v16           #ydnoteHelper:Lcom/netease/newsreader/weibo/YdNoteLoginHelper;
    :cond_1
    :goto_0
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/netease/newsreader/activity/ShareToMicroBlog$postEditMessage4Ydnote;->this$0:Lcom/netease/newsreader/activity/ShareToMicroBlog;

    move-object/from16 v17, v0

    move-object/from16 v0, v17

    iget-object v0, v0, Lcom/netease/newsreader/activity/ShareToMicroBlog;->reflashormoreDataHandler:Landroid/os/Handler;

    move-object/from16 v17, v0

    move-object/from16 v0, v17

    invoke-virtual {v0, v7}, Landroid/os/Handler;->sendMessage(Landroid/os/Message;)Z

    .line 1027
    return-void

    .line 1022
    :catch_0
    move-exception v4

    .line 1023
    .local v4, e:Ljava/lang/Exception;
    invoke-virtual {v4}, Ljava/lang/Exception;->printStackTrace()V

    goto :goto_0
.end method
